﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RzCorportativo.Lib
{
    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
    public sealed class PermissaoAttribute : Attribute
    {
        public bool HasValidation { get; set; }

        public PermissaoAttribute()
        {

        }

        public bool GetPermission(Lib.Login login, ItemSistema item)
        {
            return login.Grupos.Any(a => a.Itens != null && a.Itens.Any(a2 => a2.Nome.ToLower().Equals((item ?? new Lib.ItemSistema()).Nome.ToLower())));
        }
    }
}
